<?php
/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2020-06-22 19:08:08
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-06-23 13:59:48
 */
    //商户外卖设置页面
    require_once "config.php";
    require_once "weixin_info.php";
    $waimai_sql =$mysql->query("select * from dyspw_shop_waimai where  uid = {$_SESSION['Member_info'][0]['id']} ");
    $shop_info = $waimai_sql->fetch_all(MYSQLI_ASSOC);

    //根据配送平台门店id查询当前外卖门店详情
    // require_once "shipping.php";
    // $Shipping = new Shipping();
    // $params['shop_id'] = '1258';
    // $shop_add = $Shipping->GetMaiYaTianData('/shop/detail/',$params);
    // print_r($shop_add);exit;
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>外卖设置</title>
    <script src="js/mui.min.js"></script>
    <script src="js/mui.picker.min.js" type="text/javascript"></script>
    <link href="css/mui.min.css" rel="stylesheet" />
    <link href="css/mui.picker.min.css" rel="stylesheet" />
    <link href="css/index.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/core.css">
    <style>
        .mui-input-row input::placeholder {
            font-size: 12px;
            letter-spacing: 1px;
            color: #999 !important;
        }
        .mui-input-row input::-webkit-input-placeholder {
            font-size: 12px;
            letter-spacing: 1px;
            color: #999 !important;
        }
        .mui-input-row input::-ms-input-placeholder {
            font-size: 12px;
            letter-spacing: 1px;
            color: #999 !important;
        }
        .mui-input-row input::-moz-placeholder {
            font-size: 12px;
            letter-spacing: 1px;
            color: #999 !important;
        }

        .mui-input-row label{
            font-size: 12px;
        }

        .outer-address.mui-active:before {
            content: '是';
        }

        .outer-address.mui-active{
            background-color: #8d97b2;
            border-color: #8d97b2;
        }

        .outer-address:before {
            content: '否';
        }
        .shop-type.mui-active:before {
            content: '上架';
        }

        .shop-type.mui-active{
            background-color: #8d97b2;
            border-color: #8d97b2;
        }

        .shop-type:before {
            content: '下架';
        }
    </style>
</head>
<body>
    <section class="takeaway-box">
        <header id="header" class="mui-bar mui-bar-nav">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">外卖设置</h1>
        </header>
        <form class="mui-input-group">
            <div class="mui-input-row">
                <label>包装费</label>
                <input type="text" id="price" class="mui-input-clear" value="<?php if(!empty($shop_info)){echo $shop_info[0]['pack_fee'];} ?>" placeholder="请输入价格">
            </div>
            <div class="mui-input-row">
                <label>服务半径</label>
                <input type="text" id="radius" class="mui-input-clear" value="<?php if(!empty($shop_info)){echo $shop_info[0]['radius'];} ?>" placeholder="距你周围几公里">
            </div>
            <div class="mui-input-row">
                <label>区域</label>
                <input type="text" id="area" class="mui-input-clear" value="<?php if(!empty($shop_info)){echo $shop_info[0]['region'];} ?>" placeholder="在哪个区域配送">
            </div>
            <div class="mui-input-row">
                <label>超过区域是否配送</label>
                <div class="mui-switch outer-address <?php if(!empty($shop_info)){if($shop_info[0]['region_is'] == 1){echo 'mui-active';}} ?>">
                    <div class="mui-switch-handle"></div>
                </div>
            </div>
            <div class="mui-input-row">
                <label>配送费</label>
                <input type="text" id="delivery" class="mui-input-clear" value="<?php if(!empty($shop_info)){echo $shop_info[0]['delivery_fee'];} ?>" placeholder="请输入配送费">
            </div>
            <div class="mui-input-row">
                <label>开始营业时间</label>
                <div class="takeaway-begintime">
                    <div class="takeaway-begintime-inner"><?php if(!empty($shop_info)){echo $shop_info[0]['start_time'];}else{echo '请选择开始时间';} ?></div>
                </div>
            </div>
            <div class="mui-input-row">
                <label>结束营业时间</label>
                <div class="takeaway-begintime">
                    <div class="takeaway-endtime-inner"><?php if(!empty($shop_info)){echo $shop_info[0]['end_time'];}else{echo '请选择结束时间';} ?></div>
                </div>
            </div>
            <div class="mui-input-row">
                <label>店铺状态</label>
                <div class="mui-switch shop-type <?php if(!empty($shop_info)){if($shop_info[0]['state'] == 1){echo 'mui-active';}} ?>">
                    <div class="mui-switch-handle"></div>
                </div>
            </div>
        </form>
        <a class="takeaway-save" href="javascript:void(0);" id="saveShop">保存信息</a>
    </section>
</body>
<script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        mui.init();
        var dtPicker = new mui.DtPicker({
            type:'time'
        });
        $('.takeaway-begintime-inner').click(function() {
            dtPicker.show(function (selectItems) {
                $('.takeaway-begintime-inner').text(selectItems.value);
            })
        })
        $('.takeaway-endtime-inner').click(function() {
            dtPicker.show(function (selectItems) {
                $('.takeaway-endtime-inner').text(selectItems.value);
            })
        })

        $('#saveShop').click(function () {
            var price = $('#price').val();
            var radius = $('#radius').val();
            var area = $('#area').val();
            var delivery = $('#delivery').val();
            var isdeliver = $(".outer-address").hasClass("mui-active");
            var beginTime = $('.takeaway-begintime-inner').text();
            var endTime = $('.takeaway-endtime-inner').text();
            var shopType = $('.shop-type').hasClass("mui-active");
            $.ajax({
                url: 'waimai_ajax.php',
                type: "post",
                data: {'pack_fee':price,'radius':radius,'region':area,'region_is':isdeliver,'delivery_fee':delivery,'start_time':beginTime,'end_time':endTime,'state':shopType} ,
                dataType: 'json',
                success:function(res){
                    console.log(res);
                    if(res.status == 'y'){
                        mui.alert(res.info);
                        window.location.href = "./shop_waimai.php";
                    }else{
                        mui.alert(res.info);
                    }
                }
            })
        })
    })
</script>
</html>
